<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ page import="java.io.*, java.sql.*, java.util.*,LS.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	request.setCharacterEncoding("utf-8");
%>

<!DOCTYPE html>
<html lang="UTF-8">
<style>
.contents {
	background-color: #ffffff;
	min-height: 400px;
	margin: 2px 2px 0px 2px;
	padding: 10px 10px 0px 10px;
	text-align: left;
}

.b {
	background-color: #cccccc;
	height: 100%;
	color: white;
}

#write {
	text-align: right;
	padding-bottom: 3px;
}

th,td {
	padding-bottom: 5px;
	padding-top: 5px;
}
	
h4,h1 {
	margin: 0px;
	padding: 0px;
}

th {
	height: 30px;
	border-right: 1px solid #e5e5e5;
	border-bottom: 1px solid #e5e5e5;
}

tr {
	border-bottom: 1px solid #e5e5e5;
}

table {
	width: 100%;
}

.no {
	width: 7%;
}

.name {
	width: 13%;
}

.date {
	width: 15%;
}

.joinnumber {
	width: 10%;
}

#outerview {
	padding-top: 10px;
	margin-left: 0px;
	text-align: center;
	background-color: #fff;
	border: 1px solid #e5e5e5;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-radius: 5px;
	-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
	-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
	box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}

#outerview {
	width: 100%;
	min-height: 600px;
	padding: 0px;
}

#middleview {
	width: 90%;
	min-height: 450px;
	margin: 20px auto 0px auto;
	left: 50%;
}

#innerview {
	width: 100%;
	min-height: 450px;
	text-align: center;
	background-color: #eeeeee;
	border: 1px solid #e5e5e5;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-radius: 5px;
	-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
	-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
	box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}

#replyview {
	width: 100%;
	text-align: center;
	background-color: #eeeeee;
	border: 1px solid #e5e5e5;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-radius: 5px;
	-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
	-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
	box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}

#plusview {
	margin: 10px;
	margin-bottom: 0px;
	text-align: left;
}
</style>

<head>
<meta charset="utf-8">
<title>성공회대학교 기자재 대여 시스템</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<!-- styles시트 -->
<link href="assets/css/bootstrap.css" rel="stylesheet">
<link href="assets/css/bootstrap-responsive.css" rel="stylesheet">
<link href="assets/css/docs.css" rel="stylesheet">
<script type="text/javascript" src="assets/js/bootstrap.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$('.dropdown-toggle').dropdown();
	});
</script>
</head>

<body data-spy="scroll" data-target=".bs-docs-sidebar">
	<!-- 메뉴
    ================================================== -->
	<%
		if (session.getAttribute("user") == null) {
	%>
	<jsp:include page="/top.do"></jsp:include>
	<%
		} else {
			Users u = (Users) session.getAttribute("user");
			if (u.getUser_position().equalsIgnoreCase("S")) {
	%>
	<!-- 학생이 로그인 했을 경우 메뉴 -->
	<jsp:include page="/studenttop.do"></jsp:include>
	<%
		} else if (u.getUser_position().equalsIgnoreCase("P")) {
	%>
	<!-- 교수가 로그인 했을 경우 메뉴 -->
	<jsp:include page="/teachertop.do"></jsp:include>
	<%
		} else {
	%>
	<!-- 관리자가 로그인 했을 경우 메뉴 -->
	<jsp:include page="/managertop.do"></jsp:include>
	<%
		}
		}
	%>
	<!-- 게시판
    ================================================== -->

	<div style="text-align: center">
		<div class="marketing"
			style="margin-bottom: 30px; color: #000; text-align: left">
			<div class="container">
				<h3 style="margin: 10px; font-size: 35px;">
					<strong>공지사항</strong>
				</h3>
			</div>
		</div>
	</div>

	<div class="container">
		<div id="outerview">
			<div id="middleview">
				<div id="write">
					<%if(request.getParameter("page")!=null){ %>
					<button class="btn" onclick="document.location='notice.do?page=<%=request.getParameter("page") %>'">목록으로</button>
					<%}else{ %>
					<button class="btn" onclick="document.location='notice.do?page=1'">목록으로</button>
					<%} %>
					<%
						if(session.getAttribute("user")!=null){
						Users u = (Users) session.getAttribute("user");
					if (u.getUser_position().equalsIgnoreCase("M")) { %>
					<button class="btn"
						onclick="document.location='notice.do?delete_id=${notice.notice_id}'">삭제하자</button>
					<%}} %>
					
				</div>
				<div id="innerview">
					<table class="tableview">
						<tr class="b">
							<th class="no">${notice.notice_id}</th>
							<th class="title">${notice.title}</th>
							<th class="name">${notice.writer}</th>
							<th class="date">${notice.getDateShort()}</th>
							<th class="joinnumber">${notice.readingNumber }</th>
						</tr>
					</table>
					<div class="contents" data-spy="scroll" data-target=".navbar">
						${notice.contents}</div>
				</div>
				<div id="replyview">
					<form action="noticeRead.do" method="post">
						<input type="text" name="replyContents" style="width:80%;">
						<input type="hidden" name="page" value="<%=request.getParameter("page") %>">
						<button class="btn" name="notice_id" value="${notice.notice_id}">답글작성</button>
					</form>
					<table>
						<c:forEach var="reply" items="${reply}">
							<tr>
								<td style="width:15%;">${reply.name}</td>
								<td style="width:60%;">${reply.contents}</td>
								<td style="width:15%;">${reply.getDateShort()}</td>
<!-- 								<td><input type="submit" value="삭제하자"></td> -->
								<%
								if(session.getAttribute("user")!=null){
									Users u = (Users) session.getAttribute("user");
								if (u.getUser_position().equalsIgnoreCase("M")) { %>
								<td  style="width:10%;"><button class="btn"
										onclick="document.location='noticeRead.do?notice_id=${notice.notice_id}&deleteReplyId=${reply.reply_id}&page=<%=request.getParameter("page") %>'">삭제</button></td>
<!-- 								<td><input type="submit" class="btn" value="삭제하자"></td> -->
								<% }else {%>
									<c:if test="${reply.name == user }"><td  style="width:10%;"><button class="btn" 
									onclick="document.location='noticeRead.do?notice_id=${notice.notice_id}&deleteReplyId=${reply.reply_id}&page=<%=request.getParameter("page") %>'">삭제</button></td></c:if>
								<%}
								}%>
							</tr>
						</c:forEach>
					</table>
				</div>
				<div id="plusview">
					<form class="form-inline" style="text-align: right;">
						<select id="select01" style="width: 100px;">
							<option>전체</option>
							<option>제목</option>
							<option>작성자</option>
							<option>날짜</option>
						</select> <input type="text" class="input-middle" size=20>
						<button type="submit" class="btn">검색</button>
					</form>
				</div>
			</div>
		</div>
	</div>


	<!-- 꼬리말
    ================================================== -->
	<footer class="footer">
		<div class="container">
			<p>Copyright SKHU. Software Student.</p>
		</div>
	</footer>


	<!-- javascript -->
	<script src="assets/js/jquery.js"></script>
	<script type="text/javascript" src="assets/js/bootstrap.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			$('.dropdown-toggle').dropdown();
		});
	</script>
</body>
</html>
